// 封装用户相关操作
import ajax from '../utils/request.js'
// 登录请求
export const login = (mobile, code) => {
  return ajax({
    url: '/app/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile,
      code
    }
  })
}
// 获取用户信息
export const getUserInfo = () => {
  return ajax({
    url: '/app/v1_0/user/profile',
    method: 'GET'
    // headers: {
    //   Authorization: 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE2MTQ5NDMwMjMsInVzZXJfaWQiOjEsInJlZnJlc2giOmZhbHNlfQ.eOKxanx1LAppabVbZhELsTznC9FEVwrGxgYFlnBOYpE'
    // }
  })
}
/**
 * 关注作者
 * @param {*} authorId 作者id
 */
export const followAuthor = (authorId) => {
  return ajax({
    url: '/app/v1_0/user/followings',
    method: 'POST',
    data: {
      target: authorId
    }
  })
}
/**
 * 取关作者
 * @param {*} authorId
 */
export const delAuthor = (authorId) => {
  return ajax({
    url: '/app/v1_0/user/followings/' + authorId,
    method: 'DELETE'
  })
}
// 获取用户自身信息
export const getUser = (authorId) => {
  return ajax({
    url: '/app/v1_0/user',
    method: 'GET'
  })
}
